<template>
  <div>
    <div>苹果10￥/斤，折扣&lt;8折&gt;</div>
    <div>请输入你要购买的斤数<input type="text" v-model="kg" /></div>
    <div><button @click="click">结账买单</button></div>
    <div>
      结账单:总价{{ price }}元,折后价:{{ discount }}元,节省了{{ save }}元
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      kg: "",
      price: 0,
      discount: 0,
      save: 0,
    };
  },
  methods: {
    click() {
      this.price = parseInt(this.kg * 10);
      this.discount = parseInt((this.price / 10) * 8);
      this.save = parseInt(this.price - this.discount);
    },
  },
};
</script>

<style scoped></style>
